

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;

/**javac
 *
 */
public class count {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        count count = new count();
        count.fileReader(args[1],args[0]);
        System.out.println("success111");

    }

    public void fileReader(String filePath,String a1) {
        BufferedReader fileReader = null;
        String str=null;
        try {
            fileReader = new BufferedReader(new FileReader(filePath));
            //循环读取
            str = fileReader.readLine();

            if(a1.equals("-c")){
                System.out.println("字符数: "+str.length());
            }else if(a1.equals("-w")){
                int count=0;
                for (int j = 1; j < str.length(); j++) {
                    if((str.charAt(j-1)>=97&&str.charAt(j-1)<=122)||(str.charAt(j-1)>=65&&str.charAt(j-1)<=90)){
                        if(str.charAt(j)<65||(str.charAt(j)>90&&str.charAt(j)<97)||str.charAt(j)>122){
                            count++;
                        }
                    }
                }
                if((str.charAt(str.length()-1)>=97&&str.charAt(str.length()-1)<=122)||(str.charAt(str.length()-1)>=65&&str.charAt(str.length()-1)<=90)) {
                    count++;
                }
                System.out.println("单词数: "+count);
            }else{
                System.out.println("错误参数");
            }


        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (filePath != null) {
                try {
                    fileReader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }


        }

    }

}
